﻿using System.Drawing;
using System.Web.Mvc;
using CWB.Common.Constant;
using CWB.Common.Logging;
using CWB.Common.Utilities;
using CWB.Web.MVC.ActionResults;
using CWB.Web.MVC.Filters;

namespace CWB.WebSite.Controllers.Service
{
    public class ImageServiceController : Controller
    {
        public ImageServiceController() { }

        //
        // GET: /ImageService/

        public ImageResult Index()
        {
            CImgVerify cI = new CImgVerify();
            Bitmap bmp = cI.GenerateImage("");
            ImageResult ir = new ImageResult(ControllerContext, bmp);
            return ir;
        }

        //
        // GET: /Captcha/
        [NoClientCacheFilter]
        public ImageResult Captcha()
        {
            CImgVerify cI = new CImgVerify();
            string sTxt = cI.GetRandomAlphaNumeric();
            Session.Add(SessionKeys.VerifyCode, sTxt); ;
            Bitmap bmp = cI.GenerateImage(sTxt);
            ImageResult ir = new ImageResult(ControllerContext, bmp);
            return ir;
        }

        // Get: wav file.
        public BinaryResult Wav(string fn)
        {
            BinaryResult result = new BinaryResult(ControllerContext, fn);
            return result;
        }

    }
}
